﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.CodeDom;
using devtm.Editor.TypeSelector;

namespace devtm.Templates.Helpers
{

    public class MyType : CodeTypeReference
    {

        public MyType()
        {

        }

        public MyType(MyTypeParameter typeParameter) : base(typeParameter) { }

        public MyType(string typeName)
            : base(typeName) 
        {
            TypeExpression = BuildTypeExpression.Analyse(typeName);
        }

        public MyType(Type type)
            : base(type) 
        {
            TypeExpression = BuildTypeExpression.Analyse(type);
        }

        public MyType(BuildTypeExpression type)
            : base(type.AssemblyQualifiedName)
        {
            TypeExpression = type;
        }

        public MyType(MyType arrayType, int rank) : base(arrayType, rank) { }

        public MyType(string typeName, CodeTypeReferenceOptions codeTypeReferenceOption) : base() 
        {
            TypeExpression = BuildTypeExpression.Analyse(typeName);
        }

        public MyType(string baseType, int rank) : base(baseType, rank) 
        {
            TypeExpression = BuildTypeExpression.Analyse(baseType);
        }

        public MyType(string typeName, params MyType[] typeArguments) : base(typeName, typeArguments) 
        {
            TypeExpression = BuildTypeExpression.Analyse(typeName);
        }

        //public MyType(Type type, MyType myType)
        //    : base(type, myType)
        //{
        //    TypeExpression = BuildTypeExpression.Analyse(type);
        //}

        public BuildTypeExpression TypeExpression { get; private set; }

        public static explicit operator MyType(TypeExpression typeExpression)
        {
            return new MyType(typeExpression);
        }

    }

}
